<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('username',50)->comment("账号");
            $table->string('truename',50)->default("")->comment("真实姓名");
            $table->string("password",255)->comment("密码");
            $table->string("email",50)->nullable()->comment("邮箱");
            $table->string("phone",15)->default("")->comment("手机号");
            $table->enum("gender",["男","女"])->default("男")->comment("性别");

            //ip的长度固定, 所以用char 优化数据库字段
            $table->char("last_login_ip",15)->default("")->comment("上次登录IP");
            //create_at  update_at字段
            $table->timestamps();
            //软删除  自动生成delete_at 字段
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
